home *** CD-ROM | disk | FTP | other *** search
/ Libris Britannia 4 / science library(b).zip / science library(b) / ELECTRON / 3861.ZIP / OTHER / STRAXGEN.C < prev    next >
C/C++ Source or Header  |  1993-10-01  |  2KB  |  86 lines

  1. /*
  2.  * STRAXGEN   (TM)
  3.  * STRAXGEN.C - ScopTrax modifier for generoc output.
  4.  * Copyright (c) August 1993, Chris S. Craig
  5.  *
  6.  * UNDER NO CIRCUMSTANCES SHOULD THE MODIFIED
  7.  * SCOPTRAX.EXE FILE BE DISTRIBUTED.  ONLY THE
  8.  * ORIGINAL SCOPTRAX.ZIP FILE MAY BE DISTRIBUTED.
  9.  *
  10.  * This code may be freely distriubuted provided that the
  11.  * copyright notice is not removed and users are presented
  12.  * with the above message.
  13.  *
  14.  * Donation greatly appreciated (see SCOPTRAX.DOC for more
  15.  * info.)
  16.  *
  17.  * Use sound device "DAC on LPT1" in ScopTrax
  18.  */
  19.  
  20. #include <stdio.h>
  21.  
  22. #define PORT    5
  23. #define OFFSET  65968L
  24.  
  25. char NewCode[]=
  26. {
  27.     /*
  28.      * The 2 zerows at the end of the first line will be replaced
  29.      * by the actual port to be used.
  30.      */
  31.     0x2E, 0xC7, 0x06, 0x30, 0, 0, 0,   /* mov word ptr cs:[0030],0 */
  32.     0x31, 0xC0,                        /* xor ax,ax */
  33.     0xCB                               /* retf */
  34. };
  35.  
  36. int main( int argc, char **argv )
  37. {
  38.     int port = 0;
  39.     FILE *fp;
  40.  
  41.     puts(
  42.         "This program modifies SCOPTRAX.EXE version 1.0 so that\n"
  43.         "output will be sent to any port.\n"
  44.         "Copyright (c) 1993 Chris S. Craig\n\n"
  45.         "UNDER NO CIRCUMSTANCES SHOULD THE MODIFIED\n"
  46.         "SCOPTRAX.EXE FILE BE DISTRIBUTED.  ONLY THE\n"
  47.         "ORIGINAL SCOPTRAX.ZIP FILE MAY BE DISTRIBUTED.\n");
  48.  
  49.     if ( argc < 2 )
  50.     {
  51.         printf(
  52.             "Usage: %s <port>\n"
  53.             "\t\twhere <port> is the port address (in hex)",
  54.             argv[0] );
  55.         return 1;
  56.     }
  57.  
  58.     /* Convert the ascii port the an integer */
  59.     sscanf( argv[1], "%x", &port);
  60.     if ( port == 0 )
  61.     {
  62.         printf( "Port error.\n" );
  63.         return 2;
  64.     }
  65.  
  66.     printf( "Output will be sent to port %xH for 'DAC on LPT1'.\n", port );
  67.  
  68.     *((int *) (NewCode + PORT)) = port;
  69.  
  70.     fp = fopen( "SCOPTRAX.EXE", "rb+" );
  71.     if ( fp == NULL )
  72.     {
  73.         puts ( "SCOPTRAX.EXE muxt be in the current directory.");
  74.         return 3;
  75.     }
  76.  
  77.     fseek( fp, OFFSET, SEEK_SET );
  78.     fwrite( &NewCode, sizeof NewCode, 1, fp );
  79.  
  80.     fclose(fp);
  81.  
  82.     return 0;
  83. }
  84.  
  85.  
  86.